#!/bin/sh

APP_HOME="$(cd "$(dirname "$BASH_SOURCE")" && pwd)"
AppName=boot-mock.jar

IP="$(ifconfig eth1 | grep netmask | awk '{print $2}')"

PORT=8080

# JVM参数
JVM_OPTS="-Dname=$AppName -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=11613,suspend=n"


PID=""
query() {
  PID=$(ps -ef | grep java | grep $AppName | grep -v grep | awk '{print $2}')
}

cd "$APP_HOME" || exit

query
if [ x"$PID" != x"" ]; then
  kill -TERM "$PID"
fi
nohup java "$JVM_OPTS" -jar "$AppName" --server.port=${PORT} > mock.log >/dev/null 2>&1 &
echo "Start running..."

sleep 3
echo "Service start on : http://${IP}:${PORT}"

